/**
 * Created by Anard on 2017/4/20.
 */

var clients = require('./clients.js');

var push = module.exports;

push.public = function (obj) {
    var send = {};
    send.action = obj.action;
    send.data = obj.obj;
    clients[obj.uuid].send(JSON.stringify(send));
};

push.enter = {
    login: function (obj) {
        push.public(obj);
        clients[obj.uuid].userId = obj.obj.id;
        for (var i in clients) {
            if (i == obj.uuid) {
                continue;
            }
            if (clients[i].userId == obj.obj.id) {
                clients[i].close();
            }
        }
    }
};

push.game = {
}